package com.xr.common.businessRemind;

import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.SqlDataset;
import com.bstek.dorado.common.*;
import com.xr.common.Tools;
import com.xr.system.User;

/**
 * BusinessRemind_datasetRemindListListener
 */
public class BusinessRemind_datasetRemindListListener extends AbstractDatasetListener {
  public boolean beforeLoadData(Dataset dataset) throws Exception {
	    DoradoContext context = DoradoContext.getContext();
	    User user=(User)context.getAttribute(context.SESSION,"User");
		String sql="";
	    sql="select rmd.business_remind_id,rmd.remind_type,rmd.remind_memo,"
			+"rmd.employee_id,rmd.company_id,rmd.process_ins_id,"
			+"emp.employee_code,emp.employee_name,emp.id_card_type,emp.id_card_num,"
			+"com.company_code,com.company_chinese_name,com.company_short_name,"
			+"pi.start_time,pi.starter,ad.url,ad.activity_name_cn,ad.activity_name_en,wi.workitem_id  "    
			+"from wfl_workitem wi,wfl_process_ins pi,wfl_activity_def ad,pb_business_remind rmd,"
			+"pb_employee emp,pb_company com "    
			+"where rmd.employee_id=emp.employee_id(+) "
			+"and rmd.company_id=com.company_id(+) "
			+"and wi.process_ins_id=pi.process_ins_id "
			+"and pi.process_ins_id=rmd.process_ins_id "
			+"and wi.activity_def_id=ad.activity_def_id "
			+"and wi.participant="+user.getUserId()+"";
	    
	    SqlDataset ds = (SqlDataset) dataset;
	    String remindType = Tools.toStr(ds.parameters().getString("remind_type"));
		if (!"".equals(remindType)) {
			sql += " and rmd.remind_type ='" + remindType + "' ";
		}
		
		//System.out.println(sql);
        ds.setSql(sql);
        return true;
  }

  public void afterLoadData(Dataset dataset)
     throws Exception {

  }

}
